import cinema.model.Manager;
import cinema.service.Login;
import cinema.model.tickerSeller;
import cinema.model.customer;
import java.time.LocalDateTime;
import java.util.Scanner;
import cinema.model.systemAdmin;
import cinema.CinemaHall;
import cinema.CinemaShowTime;

public class Main {
    public static void main(String[] args) {
        CinemaShowTime.Cinema movie1 = new CinemaShowTime.Cinema("流浪地球", 125);
        CinemaShowTime.Cinema movie2 = new CinemaShowTime.Cinema("复仇者联盟", 150);
        // 创建排片系统
        CinemaShowTime schedule = new CinemaShowTime();
        // 添加场次
        schedule.addshowTimes(movie1, "1号厅", LocalDateTime.of(2025, 7, 15, 10, 0));
        schedule.addshowTimes(movie1, "3号厅", LocalDateTime.of(2025, 7, 15, 14, 30));
        schedule.addshowTimes(movie2, "IMAX厅", LocalDateTime.of(2025, 7, 15, 13, 0));
        schedule.addshowTimes(movie1, "2号厅", LocalDateTime.of(2025, 7, 15, 19, 0));
        schedule.addshowTimes(movie2, "2号厅", LocalDateTime.of(2025, 7, 15, 13, 0));

        systemAdmin systemAdmin=new systemAdmin("systemAdmin","d123456");
        Manager manager=new Manager("manager","a123456");
        tickerSeller tickerSeller=new tickerSeller("tickerSeller","b123456");
        customer customer=new customer("customer","c123456");
        boolean res1=manager.canAdd();
        boolean res2=manager.canCheck();
        boolean res3=manager.canModify();
        boolean res4=tickerSeller.canAdd();
        boolean res5=tickerSeller.canCheck();
        boolean res6=tickerSeller.canModify();
        boolean res7=customer.canAdd();
        boolean res8=customer.canCheck();
        boolean res9=customer.canModify();
        boolean r=systemAdmin.canModify();
        boolean r1=systemAdmin.canCheck();
        boolean r2=systemAdmin.canAdd();
        boolean r3=systemAdmin.canDelete();
        Login login = new Login();
        Scanner scanner5 = new Scanner(System.in);
        System.out.println("=== 电影院登录系统 ===");
        System.out.println("请选择角色（manager/tickerSeller/customer/systemAdmin）：");
        String role = scanner5.nextLine();
        System.out.println("请输入用户名：");
        String userName = scanner5.nextLine();
        System.out.println("请输入密码：");
        String passWord = scanner5.nextLine();
        if (login.login(role, userName, passWord)) {
            System.out.println("登录成功！");
            // 登录成功后，可根据不同角色跳转对应功能菜单，这里简单示例，可自行扩展
            switch (role) {
                case "systemAdmin":
                    System.out.println("进入管理员界面...");
                    System.out.println("1.修改，2.查场次，3.加场次,4.删除用户");
                    Scanner scanner9=new Scanner(System.in);
                    String s=scanner9.nextLine();
                    switch (s){
                        case "1":
                            // 调用 CinemaShowTime 的修改方法
                            schedule.modifyMovieName("流浪地球","731" );
                            break;
                        case "2":Scanner scanner=new Scanner(System.in);
                            System.out.println("请输入要查询电影：");
                            String inputName=scanner.nextLine();
                            schedule.printShowTimesForMovie(inputName);
                            break;
                        case "3":Scanner scanner6 =new Scanner(System.in);
                            manager.inputAndAddShowTime(scanner6);
                            break;
                        case "4":systemAdmin x=new systemAdmin("ccc","21");
                            x.deleteUser("123");
                            break;
                    }
                    System.out.println("能否加场:"+r2+",能否看场次:"+r1+",能否修改场次:"+r+"能否删除用户"+r3);
                    break;
                case "manager":
                    System.out.println("进入经理管理界面...");
                    System.out.println("1.修改，2.查场次，3.加场次");
                    Scanner scanner2 = new Scanner(System.in);
                    String system = scanner2.nextLine();
                    switch (system){
                        case "1":
                            // 调用 CinemaShowTime 的修改方法
                            schedule.modifyMovieName("流浪地球","731");
                            break;
                        case "2": Scanner scanner=new Scanner(System.in);
                            System.out.println("请输入要查询电影：");
                            String inputName=scanner.nextLine();
                            schedule.printShowTimesForMovie(inputName);
                            break;
                        case "3":Scanner scanner6 =new Scanner(System.in);
                            manager.inputAndAddShowTime(scanner6);
                            break;
                    }
                    System.out.println("能否加场:"+res1+",能否看场次:"+res2+",能否修改场次:"+res3);
                    break;
                case "tickerSeller":
                    System.out.println("进入售票员操作界面...");
                    System.out.println("1.查场次，2.售票");
                    Scanner scanner3 = new Scanner(System.in);
                    String system2 = scanner3.nextLine();
                    switch (system2){
                        case "1": Scanner scanner=new Scanner(System.in);

                            System.out.println("请输入要查询电影：");
                            String inputName=scanner.nextLine();
                            schedule.printShowTimesForMovie(inputName);
                            break;
                        case "2":tickerSeller d=new tickerSeller("123","xac");
                            d.selltic("流浪地球");
                            break;
                    }
                    System.out.println("能否加场:"+res4+",能否查看场次:"+res5+",能否修改场次:"+res6);
                    break;
                case "customer":
                    System.out.println("进入顾客操作界面...");
                    System.out.println("1.买票，2.查场次");
                    Scanner scanner4 = new Scanner(System.in);
                    String system3 = scanner4.nextLine();
                    switch (system3){
                        case "1":
                            Scanner scannera=new Scanner(System.in);
                            String a= scannera.nextLine();
                            Scanner scannerb=new Scanner(System.in);
                            int b= scannerb.nextInt();
                            Scanner scannerc=new Scanner(System.in);
                            int c= scannerc.nextInt();
                            CinemaHall hall=new CinemaHall("a",b,c);
                            System.out.println(hall.buyTicket(1,2));
                            break;
                        case "2": Scanner scanner=new Scanner(System.in);
                            System.out.println("请输入要查询电影：");
                            String inputName=scanner.nextLine();
                            schedule.printShowTimesForMovie(inputName);
                            break;
                    }
                    System.out.println("能否加场:"+res7+",能否查看场次:"+res8+",能否修改场次:"+res9);
                    break;
            }
        } else {
            System.out.println("用户名或密码错误，登录失败！");
        }

        scanner5.close();
    }
}